﻿<phone:PhoneApplicationPage x:Class="WinSource.Views.WritersPage"
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                            xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
                            xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                            xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                            xmlns:AppBarUtils="clr-namespace:AppBarUtils;assembly=AppBarUtils"
                            DataContext="{Binding WritersViewModel, Source={StaticResource Locator}}"
                            mc:Ignorable="d"
                            d:DesignHeight="728"
                            d:DesignWidth="480">

  <phone:PhoneApplicationPage.Resources>

    <Style x:Key="PhoneTextTitle0Style"
           TargetType="TextBlock">
      <Setter Property="FontFamily"
              Value="{StaticResource PhoneFontFamilySemiBold}" />
      <Setter Property="Foreground"
              Value="{StaticResource RedColor}" />
      <Setter Property="FontSize"
              Value="{StaticResource PhoneFontSizeMedium}" />
    </Style>

    <Style x:Key="PivotStyle"
           TargetType="controls:Pivot">
      <Setter Property="Background"
              Value="{StaticResource BackgroundColor}" />

      <Setter Property="TitleTemplate">
        <Setter.Value>

          <DataTemplate>

            <TextBlock Style="{StaticResource PhoneTextTitle0Style}"
                       Foreground="{StaticResource RedBrush}"
                       Margin="0,-1,0,-3"
                       Text="{Binding}" />

          </DataTemplate>

        </Setter.Value>

      </Setter>

      <Setter Property="HeaderTemplate">
        <Setter.Value>

          <DataTemplate>

            <TextBlock Foreground="Black"
                       Margin="-2,0,1,0"
                       Text="{Binding}"
                       TextWrapping="Wrap" />

          </DataTemplate>

        </Setter.Value>

      </Setter>

    </Style>

  </phone:PhoneApplicationPage.Resources>

  <Grid>

    <controls:Pivot Title="{StaticResource ApplicationName}"
                    Style="{StaticResource PivotStyle}"
                    x:Name="pivot" SelectionChanged="PivotSelectionChanged">

      <controls:PivotItem DataContext="{Binding WriterJoe}"
                          Header="{Binding Name}"
                          Tag="{Binding Name}">

        <Grid Margin="12,0">

          <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
          </Grid.RowDefinitions>

          <Image Height="180"
                 HorizontalAlignment="Left"
                 Source="{Binding Image}"
                 Stretch="Fill"
                 VerticalAlignment="Top"
                 Width="180" />

          <TextBlock Grid.Row="1"
                     Style="{StaticResource TextBlockBlackStyle}"
                     Margin="0,12,0,0"
                     Text="{Binding Description}"
                     TextWrapping="Wrap" />

        </Grid>

      </controls:PivotItem>

      <controls:PivotItem DataContext="{Binding WriterAshley}"
                          Header="{Binding Name}"
                          Tag="{Binding Name}">

        <Grid Margin="12,0">

          <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
          </Grid.RowDefinitions>

          <Image Height="180"
                 HorizontalAlignment="Left"
                 Source="{Binding Image}"
                 Stretch="Fill"
                 VerticalAlignment="Top"
                 Width="180" />

          <TextBlock Grid.Row="1"
                     Style="{StaticResource TextBlockBlackStyle}"
                     Margin="0,12,0,0"
                     Text="{Binding Description}"
                     TextWrapping="Wrap" />

        </Grid>

      </controls:PivotItem>

    </controls:Pivot>

  </Grid>

  <phone:PhoneApplicationPage.ApplicationBar>

    <shell:ApplicationBar BackgroundColor="{StaticResource RedColor}"
                          ForegroundColor="White"
                          IsVisible="True">

      <shell:ApplicationBarIconButton IconUri="/Assets/Shares/Email.png"
                                      Text="email" />

    </shell:ApplicationBar>

  </phone:PhoneApplicationPage.ApplicationBar>

  <i:Interaction.Behaviors>

    <AppBarUtils:AppBarItemCommand Id="email"
                                   Command="{Binding WriteEmailCommand}" />

  </i:Interaction.Behaviors>

</phone:PhoneApplicationPage>